<template>
  <span class="sjht-search-submit">
    <a-form-item>
      <a-space>
        <a-button type="primary" htmlType="submit">查询</a-button>
        <a-button v-if="!hideReset" htmlType="reset" @click="$emit('reset')">重置</a-button>
        <a v-if="ismore" @click.stop="change" class="sjht-select-none">
          {{ more ? '收起' : '展开' }}
          <a-icon :type="`caret-${more?'up':'down'}`" />
        </a>
      </a-space>
    </a-form-item>
    <div class="sjht-search-submit-more" v-show="more">
      <slot></slot>
    </div>
  </span>
</template>
<script>
export default {
  name: 'SjhtSearchSubmit', //搜索表单-查询和重置
  props: {
    hideReset: Boolean //隐藏重置按钮
  },
  data() {
    return {
      more: false //展开|收起
    }
  },
  methods: {
    //切换事件 展开/收起
    change() {
      this.more = !this.more
      if (this.ismore) this.$emit('change', this.more)
    }
  },
  computed: {
    //是否有更多展开/收起  根据插槽默认default具名插槽判断
    ismore: function () {
      return Boolean(this.$slots?.default)
    }
  }
}
</script>